home *** CD-ROM | disk | FTP | other *** search
-
- #####################################################################
- #####################################################################
- ## ##
- ## BOOK TEXT VIEW CREATION ##
- ## ##
- #####################################################################
- #####################################################################
-
- dwScript Plain__BookTextView {
- dwProcessTemplate Plain__BookTextViewTmpl
- }
-
- dwTemplate Plain__BookTextViewTmpl {
- $[dwCall dwMakeUrlParts]
- <HTML>
- <HEAD>
- <TITLE>$[dwGetRootTitle]</TITLE>
- </HEAD>
- <BODY>
- <!-- SGISTART:$[dwGetRootTitle] -->
- $[dwInitPageTextGenerator [dwGet TextStylesheet] [dwGet DoReveal]]
- $[dwCall Generic__GeneratePageText]
- <!-- SGIEND:$[dwGetRootTitle] -->
- </BODY>
- </HTML>
- }
-
-
- dwScript Generic__GeneratePageText {
- set keep_going 1
- set text_size 0
-
- ## initialize to empty string since there is currently no link
- dwSet ahref ""
-
- dwFlushPipe
-
- while {$keep_going} {
- set text [dwGetPageText]
- dwSend $text
- set text_size [expr $text_size + [string length $text]]
-
- set interrupt [dwGetPageInterrupt]
- switch -exact $interrupt {
- end_of_page {set keep_going 0}
- exceeded_page_size {set keep_going 1}
- start_script {dwCall Generic__HandleStartScript}
- end_script {dwCall Generic__HandleEndScript}
- inline_figure {dwCall Generic__HandleInlineFigure}
- inline_icon {dwCall Generic__HandleInlineIcon}
- default {}
- }
- }
- }
-
-
- dwScript Plain__BookTocTextView {
-
- dwInitTocLineGenerator 5 [dwGet State__TocStyle]
- dwSet HilitePosition 0
- dwSet TocTitleBefore ""
- dwSet TocTitleAfter ""
- dwSet TopScrollPoint ""
- dwSet ScrollPosition ""
- dwSet ShowingTocView 1
-
- set skip_item 0
- set title [dwGetRootTitle]
- regsub -all {\<[\/-z]+\>} $title {} title
-
- dwSetContentType "text/plain"
-
- if {[dwGetTocNumEntries] > 1} {
-
- dwSend "0|$title|0\n";
- while {[dwNewTocLine]} {
-
- set title [dwGetTocItemTitle]
- regsub -all {\<[\/-z]+\>} $title {} title
-
- if {[dwGetTocItemLevel] == 1 && ([dwGetTocItemTitle] == "Glossary" || [dwGetTocItemTitle] == "Index")} {
- dwSend "[dwGetTocItemLevel]|[string trimleft $title {" "}]|[dwGetTocItemPath]\n";
- set skip_item 1
- }
-
- if {$title != "" && $skip_item == 0} {
- dwSend "[dwGetTocItemLevel]|[string trimleft $title {" "}]|[dwGetTocItemPath]\n";
- }
- }
- }
- }
-
-
- #####################################################################
- ## ##
- ## SCRIPT HANDLERS ##
- ## ##
- #####################################################################
-
- dwScript Generic__HandleInlineIcon {
- dwCall Generic__ProcessScriptInfo
-
- set icon_name [dwGet Script_name]
- set icon_file images/[string tolower ${icon_name}.gif]
-
- dwSet Inline_imgSrc $icon_file
- dwSet Inline_imgAlt $icon_name
- dwSet Inline_imgBorder 0
- dwSet Inline_imgAlign absmiddle
- dwCall Generic__InlineHandler
- }
-
- dwScript Generic__HandleInlineFigure {
-
- dwCall Generic__ProcessScriptInfo
-
- if {[dwGet Script_name] == "custom"} {
- dwCall Generic__HandleStartScript
- } else {
- dwSet Inline_imgSrc images/[dwGet Script_fname]
- dwSet Inline_imgAlt [dwGet Script_fname]
- dwSet Inline_imgBorder 0
- dwSet Inline_imgAlign absmiddle
- dwCall Generic__InlineHandler
- }
- }
-
- dwScript Generic__InlineHandler {
- if {[dwGet Inline_imgAlt] == "sgilink"} {
- ;
- } else {
- dwProcessTemplate Generic__InlineHtml
- }
- }
-
- dwTemplate Generic__InlineHtml {
- <IMG SRC="$[dwGet Inline_imgSrc]" ALT="$[dwGet Inline_imgAlt]" BORDER="$[dwGet Inline_imgBorder]" ALIGN="$[dwGet Inline_imgAlign]">
- }
-
-
- ##=========================================================================##
- ## These scripts handle EBT stylesheet <script>s.
- ##=========================================================================##
-
- dwScript Generic__HandleStartScript {
-
- dwCall dwMakeUrlParts
- dwCall Generic__ProcessScriptInfo
-
- set script [dwGet Script_name]
- set params [dwGet Script_params]
-
- switch -exact $script {
- sgi-glossary {}
- ebt-launch {dwCall SetUpEbtLaunch}
- default {
- if {[dwGet Script_params] == ""} {
- dwSend "<A HREF=\"@$script\">"
- } else {
- dwSend "<A HREF=\"@$script?$params\">"
- }
- }
- }
- }
-
- dwScript Generic__HandleEndScript {
-
- dwCall Generic__ProcessScriptInfo
-
- switch -exact [dwGet Script_name] {
- sgi-glossary {}
- default {dwSend "</A>"}
- }
- }
-
- ##=========================================================================##
- ## Get the interrupt info for the script, and massage it into a form
- ## suitable for stashing it as the "query params" of a URL.
- ## TODO: a [dwUrlEncode string] command of some sort.
- ##=========================================================================##
-
- dwScript Generic__ProcessScriptInfo {
-
- ## Get the script information (script-name param1=valu1 param2=value2 ...)
- ## Break apart the parameter/value sets (param=value ==> param = value)
- ## because TCL gets confused by embedded quotes (param="value with spaces")
-
- set info [dwGetPageInterruptInfo]
- regsub -all {= } $info {="" } info
- regsub -all {=} $info { = } info
-
- ## Script name is easy!
- dwSet Script_name [lindex $info 0]
-
- ## Initialize some stuff.
- dwSet Script_params ""
- dwSet Script_book ""
- dwSet Script_collection ""
- dwSet Script_window ""
- dwSet Script_target ""
- dwSet Script_currentPath ""
- dwSet Script_fname ""
-
- dwSet Script_containsHit 0
- set gotBook 0
- set gotCollection 0
- set gotWindow 0
- set gotTarget 0
- set gotMe 0
- set gotHit 0
- set gotTname 0
- set gotTvalue 0
- set gotFname 0
-
- ## Now glue the list back together, separating param/value pairs by ";"s.
- ## Also url-encode them.
- set nitems [llength $info]
- if {$nitems > 1} {
- set next_sep {;}
- for {set i 1} {$i < $nitems} {incr i} {
- set sep $next_sep
- set next_sep {;}
- set item [lindex $info $i]
-
- ## No semicolons around the "="!
- ## Also, as aspecial favor to ebt-link, we keep track of
- ## book= and collection= params.
- if {$item == "="} {
- set sep ""
- set next_sep ""
- } else {
- if {$sep == ";"} {
- set gotBook 0
- set gotCollection 0
- set gotWindow 0
- set gotTarget 0
- set gotTname 0
- set gotTvalue 0
- set gotFname 0
- set gotMe 0
- set getHit 0
- if {[string tolower $item] == "book"} {
- set gotBook 1
- } elseif {[string tolower $item] == "collection"} {
- set gotCollection 1
- } elseif {[string tolower $item] == "window"} {
- set gotWindow 1
- } elseif {[string tolower $item] == "target"} {
- set gotTarget 1
- } elseif {[string tolower $item] == "__me__"} {
- set gotMe 1
- } elseif {[string tolower $item] == "__hit__"} {
- set gotHit 1
- } elseif {[string tolower $item] == "tvalue"} {
- set gotTvalue 1
- } elseif {[string tolower $item] == "tname"} {
- set gotTname 1
- } elseif {[string tolower $item] == "filename"} {
- set gotFname 1
- } elseif {[string tolower $item] == "parm1"} {
- set gotFname 1
- }
-
- } elseif {$gotBook} {
- set Script_book $item
- } elseif {$gotCollection} {
- set Script_collection $item
- } elseif {$gotWindow} {
- set Script_window [string tolower $item]
- } elseif {$gotTarget} {
- set Script_target $item
- } elseif {$gotMe} {
- set Script_currentPath $item
- } elseif {$gotHit} {
- set Script_containsHit $item
- } elseif {$gotTvalue} {
- set Script_target IDMATCH(id,$item)
- set newitem target=$Script_target
- set item $newitem
- set sep {;}
- set gotTvalue 0
- } elseif {$gotFname} {
- set Script_fname $item
- }
- }
-
- if {[llength $item] > 1} {
- set item \"$item\"
- regsub -all { = } $item {=} item
- }
-
- if {$gotTvalue} {
- } elseif {$gotTname} {
- } else {
- dwSet Script_params "$Script_params$sep[dwUrlEncode $item]"
- }
- }
- }
-
- ## Don't propagate internally generated state info.
- regsub -all {__[^_]*__=[^;]*} $Script_params {} Script_params
-
- ## Clean up extraneous ;'s
- regsub -all {;;} $Script_params {;} Script_params
- set Script_params [string trim $Script_params ";"]
-
- ## Don't blindly pass up a null script name
- if {$Script_name == ""} {dwSet Script_name "script_error"}
-
- ## Don't return anything
- dwReturn
- }
-
-
- dwScript SetUpEbtLaunch {
-
- set info [dwGetPageInterruptInfo]
- set nrcheck "bin/nr"
- set len [string last $nrcheck $info]
-
- if {$len > 0} {
- set full_len [expr $len+[string length $nrcheck]]
- set tmp [string range $info $full_len end]
- set ftmp [string trimright $tmp {";,}]
- set tmp [string trimleft $ftmp {" "}]
- dwSend "<A HREF=\"$tmp\" TARGET=\"_blank\">"
- } else {
- dwSend "<A NAME=\"sgi_no_link\">"
- }
- }
-
-
- ##===========================================================================
- ## URL construction utilities.
- ##===========================================================================
-
- #############################################################################
- ## ##
- ## Mostly by convention, the DynaWeb URL looks something like: ##
- ## ##
- ## http://www.ebt.com/<service>/<path>;<url_params>?<query_params> ##
- ## ##
- ## where <service> is usually "dynaweb" and where <path> consists of: ##
- ## ##
- ## <root_path>/@<script_name>/<selection> ##
- ## ##
- ## and where <root_path> consists of: ##
- ## ##
- ## <collection_name>/<collection_name>/.../<book_name> ##
- ## ##
- ## Note that <script> may refer to either a dwScript or a dwTemplate, ##
- ## and <selection> semantics are script-dependent. ##
- ## ##
- ## Example: ##
- ## ##
- ## http://www.ebt.com/dynaweb/Manuals/Admin_guide/@BookTocView/446 ##
- ## | | | | | ##
- ## Service-------+ | | | | ##
- ## Collection---+ | | | ##
- ## Book--------+ | | ##
- ## Viewing template--+ | ##
- ## Target node--+ ##
- ## ##
- #############################################################################
- #############################################################################
-
- ##==============================================================================
- ## Build URL fragments that are suitable for constructing
- ## different kinds of URLs. The following parts are made:
- ##
- ## BaseUrl - A fully qualified URL including the root path
- ## (note: ends with a '/'). Suitable for use as a <BASE> HREF.
- ## Example: http://www.foo.com/dynaweb/collection/book/
- ##
- ## BasePath - Like the BaseUrl, but does not include the
- ## scheme, host, or port, and does not end with '/'.
- ## Suitable for use as a relative Url.
- ## Example: /dynaweb/collection/book
- ##
- ## RootAbsUrlPath - Like BasePath, but does not include the
- ## URL prefix or service.
- ## Example: /collection/book
- ##
- ## UrlQueryString - If a query is active this will be a string
- ## representing the query preceded by a '?' that is
- ## suitable for tacking on the end of URLs
- ## Example: ?DwebQuery=this+is+a+search+string
- ##
- ## UrlParamString - This is a string that is suitable for
- ## inserting in the URL between the path and the
- ## query string. It contains state variables for
- ## the current "session".
- ## Example: ;td=3;hf=1
- ##
- ## Careful: If RootPath is empty, avoid sending back a trailing slash.
- ##=============================================================================
-
- dwScript dwMakeUrlParts {
- set root [dwGetRootPath]
- set service [dwGetUrlNthPathSeg 0]
- set prefix [dwGetUrlPrefix]
- set script [dwGetUrlNthPathSeg [expr [dwGetUrlNumPathSegs] - 1]]
-
- if {$prefix == "/"} {set prefix ""}
-
- ## Build BasePath, RootAbsUrlPath, and BaseUrl
-
- dwSet BasePath $prefix/$service
- dwSet Service $service
-
- if {$root == ""} {
- dwSet RootAbsUrlPath $prefix/$service
- } else {
- dwSet RootAbsUrlPath $prefix/$service/$root
- }
-
- set port [dwGetUrlPort]
- if {$port == "80"} {
- dwSet dwPort :$port
- } else {
- set dwPort ""
- }
-
- dwSet UrlQueryString ""
- dwSet UrlParamString ""
- dwSet BaseUrl \
- "[dwGetUrlScheme]://[dwGetUrlServer]:[dwGetUrlPort]$RootAbsUrlPath/"
-
- dwReturn
- }
-
-